#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QSize>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // renew

    // 普通按钮(无check属性)
    ui->NormalBtn->setText("普通按钮");
    ui->NormalBtn->setIcon(QIcon(":/icons/camera.png"));
    ui->NormalBtn->setIconSize(QSize(25, 25));
    connect(ui->NormalBtn, &QPushButton::clicked, this, [=]()
    {
       qDebug() << "普通按钮被按下了...";
    });

    // Check按钮
    ui->CheckBtn->setCheckable(true);
    connect(ui->CheckBtn, &QPushButton::toggled, this, [=](bool status)
    {
        qDebug() << "拥有Check属性的普通按钮被按下了... 当前状态为:" << status;
    });

    // menu按钮
    // 关联菜单
    ui->MenuBtn->setText("选择要使用的语言");
    QMenu* menu = new QMenu;
    QAction* act = menu->addAction("C语言");
    menu->addAction("C语言");
    menu->addAction("C++");
    menu->addAction("Java");
    menu->addAction("Python");
    ui->MenuBtn->setMenu(menu);
    connect(act, &QAction::triggered, this, [=]
    {
       qDebug() << "您选择了c语言";
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

